def fibonacci(n):
   """ 生成斐波那契数列的前n项 """
   fib_sequence = [0, 1]
   while len(fib_sequence) < n + 1:  # 确保生成n+1项，因为从F(0)开始
       fib_sequence.append(fib_sequence[-1] + fib_sequence[-2])
   return fib_sequence[1:]  # 从1开始，因为半径从F(1)开始

def main():
   steps = 50
   fib_radii = fibonacci(steps)
   
   total_length = 0
   ratios = []
   
   # 初始化previous_length为第一个弧线的长度
   previous_length = 2 * 3.14159 * fib_radii[0]
   total_length += previous_length
   
   for i in range(1, steps):  # 从1开始循环，因为第0步已经处理过了
       length = 2 * 3.14159 * fib_radii[i]
       ratio = length / previous_length
       ratios.append(ratio)
       
       total_length += length
       previous_length = length
   
   print("Total length of the first 50 steps of the Fibonacci spiral:", total_length)
   print("Ratios of consecutive lengths:")
   for ratio in ratios:
       print(ratio)

main()